Data from National Highway Traffic Safety Administration (NHTSA) on fatal traffic accidents in the US
Collected and reported annually from 1975. Most recent year available is 2022
For each state, I calculated the following:
Number of crashes per 1000 population (all_crash_per_capita)
Number of crashes on nice days per 1000 population (nice_crash_per_capita)
Number of crashes on “not nice” days per 1000 population (not_nice_crash_per_capita)
Number of crashes on other days per 1000 population (other_crash_per_capita)
Ratio of crashes on nice days vs crashes on not nice days (ratio_nice_not_nice)
Nice day: Either Clear or Cloudy weather and Daylight light conditions
Not nice day = Either Blowing Sand, Soil, Dirt, Blowing Snow, Fog, Smog, Smoke, Freezing Rain or Drizzle, Rain, Severe Crosswinds, Sleet or Hail, or Snow or Dark - Not Lighted, Dawn, or Dusk light conditions
Perception of color can vary. (a,b) The same color can look different (a), and different colors can appear to be nearly the same by changing the background color (b)1. (c) The rectangles in the heat map indicated by the asterisks (*) are the same color but appear to be different.
Figure 1 from Wong (2010a)
Common pitfalls / Recommendations
Ignoring color blindness
Use color-blind friendly color palettes when possible
Too Much Information
Use containment or other aesthetics to assist interpretation
Avoid using more than 6-8 colors in a plot (Wong, 2011)
Misleading comparisons
Viewers have difficulty mapping color changes to quantitative variables
Color scales
Consider how colors relate to each other, background
Code Together Task
No Spice: Use fars2022_summary to create the plot on slide 6.
Weak Sauce: Use fars2022_summary to create the plot on slide 8. You will need to use the scale_color_brewer() option in ggplot2
Medium Spice: Use fars2022_summary and fars2022_regional_summary to create the plot on slide 11
Yoga Flame: Use fars2022_summary to create the plot on slide 9. You will need to install and load the ggrepel package and use geom_text_repel() or geom_label_repel()
Dim Mak: Use fars2022_summary to create the plot on slide 12. Hint: On slide 12 I give you code to create a dataset containing the polygons (the ‘convex hulls’). You will need to use geom_polygon()